<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
	<ui:composition template="../template/commonLayoutFull.xhtml">
		<ui:define name="content">
			<h:panelGrid style="height: 100%; width: 100%;">

				<p:fieldset legend="Risco" style="height:100%;" toggleable="true"
					toggleSpeed="">

					<!-- Cadastro de Demanda | Histórico | Parametrização: MODAL -->
					<p:dialog id="dgCadastro" header="Cadastro de Risco"
						widgetVar="modalCadastro" modal="true" height="450"
						appendToBody="true">
								<h:form>
									<h:panelGrid  columns="4" cellpadding="5" id="pnCadRisco">

										<p:row>
											<p:column>
												<p:outputLabel value="Cliente: " />
												<h:selectOneMenu
													value="#{riscoBean.riscoCadastro.risco.idCliente.id}">
													<f:selectItem itemLabel="Selecione" itemValue="0" />
													<f:selectItems value="#{riscoBean.clientes.itens}" />
												</h:selectOneMenu>
												<p:outputLabel value=" ou " />
												<p:inputText value="#{riscoBean.riscoCadastro.risco.nomeCliente}" />
											</p:column>
										</p:row>

										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Descrição: " />
												<p:inputText
													value="#{riscoBean.riscoCadastro.risco.descricaoRisco}" size="40" />
											</p:column>
										</p:row>

										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Data Identificação: " />
												<p:calendar
													value="#{riscoBean.riscoCadastro.risco.dataIdentificacao}"
													showOn="button" />
											</p:column>
										</p:row>

										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Tipo: " />
												<h:selectOneMenu
													value="#{riscoBean.riscoCadastro.risco.idTipoRisco.id}">
													<f:selectItem itemLabel="Selecione" itemValue="0" />
													<f:selectItems value="#{riscoBean.tipos.itens}" />
												</h:selectOneMenu>
											</p:column>
										</p:row>
										
										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Probabilidade: " />
												<h:selectOneMenu
													value="#{riscoBean.riscoCadastro.risco.idProbabilidade.id}">
													<f:selectItem itemLabel="Selecione" itemValue="0" />
													<f:selectItems value="#{riscoBean.probabilidades.itens}" />
												</h:selectOneMenu>
											</p:column>
										</p:row>

										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Possui carta de risco: " />
												<h:selectOneMenu
													value="#{riscoBean.riscoCadastro.risco.cartaRisco}">
													<f:selectItem itemLabel="Não" itemValue="0" />
													<f:selectItem itemLabel="Sim" itemValue="1" />
												</h:selectOneMenu>
											</p:column>
										</p:row>

										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Impacto: " />
												<h:selectOneMenu
													value="#{riscoBean.riscoCadastro.risco.idImpacto.id}">
													<f:selectItem itemLabel="Selecione" itemValue="0" />
													<f:selectItems value="#{riscoBean.impactos.itens}" />
												</h:selectOneMenu>
											</p:column>
										</p:row>
										
										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Status: " />
												<h:selectOneMenu
													value="#{riscoBean.riscoCadastro.risco.idStatusRisco.id}">
													<f:selectItem itemLabel="Selecione" itemValue="0" />
													<f:selectItems value="#{riscoBean.status.itens}" />
												</h:selectOneMenu>
											</p:column>
										</p:row>
										
										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Responsável: " />
												<h:selectOneMenu
													value="#{riscoBean.riscoCadastro.risco.idResponsavel.id}">
													<f:selectItem itemLabel="Selecione" itemValue="0" />
													<f:selectItems value="#{riscoBean.usuarios.itens}" />
												</h:selectOneMenu>
											</p:column>
										</p:row>

										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Data Prevista Mitigação: " />
												<p:calendar
													value="#{riscoBean.riscoCadastro.risco.dataPrevistaMitigacao}"
													showOn="button" />
											</p:column>
										</p:row>
										
										<br />

										<p:row>
											<p:column>
												<p:outputLabel value="Data Efetiva Mitigação: " />
												<p:calendar
													value="#{riscoBean.riscoCadastro.risco.dataMitigacaoEfetiva}"
													showOn="button" />
											</p:column>
										</p:row>
										
										<br />
										
										<p:row>  
							    			<p:column><p:outputLabel value="Ação Mitigação: "/></p:column>
							    			<br />
								            <p:column colspan="3">  
								                <p:inputTextarea rows="5" cols="50" maxlength="250" autoResize="false" value="#{riscoBean.riscoCadastro.risco.acoesMitigacao}"/> 
								            </p:column>  
								        </p:row>
								        
								        <br />
										
										<p:row>  
							    			<p:column><p:outputLabel value="Observações: "/></p:column>
							    			<br />
								            <p:column colspan="3">  
								                <p:inputTextarea rows="5" cols="50" maxlength="250" autoResize="false" value="#{riscoBean.riscoCadastro.risco.observacoes}"/> 
								            </p:column>  
								        </p:row>

									</h:panelGrid>
									<p:separator />
									<p:commandButton id="salvarRisco" value="Salvar"
										action="#{riscoBean.salvarRisco}" />
								</h:form>
					</p:dialog>

					<!-- Filtro de Pesquisa de Demanda -->

					<h:form>
						<p:fieldset legend="Filtros" style="height:70%;" toggleable="true"
							toggleSpeed="">
							<h:panelGrid columns="4" cellpadding="5">
								<p:outputLabel value="Data Mitigação Prevista:" />
								<p:calendar
									value="#{riscoBean.riscoConsulta.dtMitigacaoPrevistaIni}"
									showOn="button" />
								<p:outputLabel value="até:" />
								<p:calendar
									value="#{riscoBean.riscoConsulta.dtMitigacaoPrevistaFin}"
									showOn="button" />
								<p:outputLabel value="Data Mitigação Efetiva:" />
								<p:calendar
									value="#{riscoBean.riscoConsulta.dtMitigacaoEfetivaIni}"
									showOn="button" />
								<p:outputLabel value="até:" />
								<p:calendar
									value="#{riscoBean.riscoConsulta.dtMitigacaoEfetivaFin}"
									showOn="button" />
								<p:outputLabel value="Data Identificação:" />
								<p:calendar
									value="#{riscoBean.riscoConsulta.dtIdentificacaoIni}"
									showOn="button" />
								<p:outputLabel value="até:" />
								<p:calendar
									value="#{riscoBean.riscoConsulta.dtIdentificacaoFin}"
									showOn="button" />
								<p:outputLabel value="Probabilidade" />
								<h:selectOneMenu
									value="#{riscoBean.riscoConsulta.idProbabilidade}">
									<f:selectItem itemLabel="Selecione" itemValue="0" />
									<f:selectItems value="#{riscoBean.probabilidades.itens}" />
								</h:selectOneMenu>
								<p:outputLabel value="Status:" />
								<h:selectOneMenu value="#{riscoBean.riscoConsulta.idStatus}">
									<f:selectItem itemLabel="Selecione" itemValue="0" />
									<f:selectItems value="#{riscodemandaBean.status.itens}" />
								</h:selectOneMenu>
								<p:outputLabel value="Tipo:" />
								<h:selectOneMenu value="#{riscoBean.riscoConsulta.idTipo}">
									<f:selectItem itemLabel="Selecione" itemValue="0" />
									<f:selectItems value="#{riscoBean.tipos.itens}" />
								</h:selectOneMenu>
								<p:outputLabel value="Responsável" />
								<h:selectOneMenu
									value="#{riscoBean.riscoConsulta.idResponsavel}">
									<f:selectItem itemLabel="Selecione" itemValue="0" />
									<f:selectItems value="#{riscoBean.usuarios.itens}" />
								</h:selectOneMenu>
								<p:outputLabel value="Cliente" />
								<h:selectOneMenu value="#{riscoBean.riscoConsulta.idCliente}">
									<f:selectItem itemLabel="Selecione" itemValue="0" />
									<f:selectItems value="#{demandaBean.clientes.itens}" />
								</h:selectOneMenu>
							</h:panelGrid>

							<br />
							<br />

							<p:commandButton id="pesquisarRisco" value="Pesquisar"
								action="#{riscoBean.pesquisarRisco}" />
						</p:fieldset>
						<br />
						<br />

						<p:separator />
						<br />
						<p:commandButton id="modalDialogButton" value="Incluir"
							onclick="modalCadastro.show();" type="button" />
						<br />
						<br />
						<p:separator />

						<!-- Lista de Demanda: GRID -->
						<p:dataTable id="tableRiscos" var="risco"
							value="#{riscoBean.riscos}" paginator="true" rows="20"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							rowsPerPageTemplate="5,10,15" style="">
							<f:facet name="header">  
					            Riscos  
					        </f:facet>
							<p:column sortBy="#{demanda.idCliente}" headerText="Cliente">
								<h:outputText value="#{demanda.solicitante}" />
							</p:column>
							<p:column sortBy="#{demanda.descricao}" headerText="Descrição">
								<h:outputText value="#{demanda.dtSolicitacao}" />
							</p:column>
							<p:column sortBy="#{demanda.dataIdentificacao}"
								headerText="Data Identificação">
								<h:outputText value="#{demanda.dtConclusao}" />
							</p:column>
							<p:column sortBy="#{demanda.idTipo}" headerText="Tipo">
								<h:outputText value="#{demanda.prioridade}" />
							</p:column>
							<p:column sortBy="#{demanda.cartaRisco}"
								headerText="Carta de risco">
								<h:outputText value="#{demanda.status}" />
							</p:column>
							<p:column sortBy="#{demanda.idImpacto}" headerText="Impacto">
								<h:outputText value="#{demanda.esforco}" />
							</p:column>
							<p:column sortBy="#{demanda.idProbabilidade}"
								headerText="Probabilidade">
								<h:outputText value="#{demanda.atividade}" />
							</p:column>
							<p:column sortBy="#{demanda.idStatus}" headerText="Status">
								<h:outputText value="#{demanda.acao}" />
							</p:column>
							<p:column sortBy="#{demanda.idResponsavel}"
								headerText="Responsável">
								<h:outputText value="#{demanda.cliente}" />
							</p:column>
							<p:column sortBy="#{demanda.dataMitigacaoPrevista}"
								headerText="Data prevista Mitigação">
								<h:outputText value="#{demanda.cliente}" />
							</p:column>
							<p:column sortBy="#{demanda.dataMitigacaoEfetiva}"
								headerText="Data efetiva Mitigação">
								<h:outputText value="#{demanda.cliente}" />
							</p:column>
						</p:dataTable>

						<!-- Export em Arquivo -->
						<h:panelGrid width="100%" style="text-align:left;"
							collapsible="true" gutter="0">
							<p:separator />
							<p:outputLabel value="Exportar em Arquivo:">
								<h:commandLink>
									<img src="#{request.contextPath}/images/xls.png" height="32"
										width="32" />
									<p:dataExporter type="xls" target="tableRiscos"
										fileName="riscos" />
								</h:commandLink>
								<h:commandLink>
									<img src="#{request.contextPath}/images/pdf.png" height="32"
										width="32" />
									<p:dataExporter type="pdf" target="tableRiscos"
										fileName="riscos" />
								</h:commandLink>
								<h:commandLink>
									<img src="#{request.contextPath}/images/csv.png" height="32"
										width="32" />
									<p:dataExporter type="csv" target="tableRiscos"
										fileName="riscos" />
								</h:commandLink>
								<h:commandLink>
									<img src="#{request.contextPath}/images/xml.png" height="32"
										width="32" />
									<p:dataExporter type="xml" target="tableRiscos"
										fileName="riscos" />
								</h:commandLink>
							</p:outputLabel>
						</h:panelGrid>
					</h:form>
				</p:fieldset>
			</h:panelGrid>
		</ui:define>
	</ui:composition>
</h:body>
</html>